package com.example.news.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.example.news.R;
import com.example.news.bean.OneBean;

import java.util.ArrayList;

public class OneAdapter extends BaseAdapter {

    private ArrayList<OneBean> list;
    private Context context;

    public OneAdapter(ArrayList<OneBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View rootView, ViewGroup viewGroup) {
        rootView = LayoutInflater.from(context).inflate(R.layout.one_iteam, viewGroup, false);
         TextView tv_neirong = (TextView) rootView.findViewById(R.id.tv_neirong);
         ImageView img_one= (ImageView) rootView.findViewById(R.id.img_one);
         ImageView img_two = (ImageView) rootView.findViewById(R.id.img_two);
         ImageView img_three = (ImageView) rootView.findViewById(R.id.img_three);
         tv_neirong.setText(list.get(i).getName());
         img_one.setImageResource(list.get(i).getImg_one());
         img_two.setImageResource(list.get(i).getImg_two());
         img_three.setImageResource(list.get(i).getIng_three());
        return rootView;
    }


}
